import 'package:flutter/material.dart';
import 'package:read_book/data/book_mall/book_mall.dart';

import 'catalog.dart';

class BookContent extends StatefulWidget {
  String bookLink;
  String bookId;

  BookContent({Key key, this.bookLink, this.bookId}) : super(key: key);

  @override
  _BookContentState createState() => _BookContentState();
}

class _BookContentState extends State<BookContent> {
  Map bookContent = {};

  //获取排行榜数据
  void getBookContent(link) {
    BookMall().getBookContent(link).then((value) {
      setState(() {
        bookContent = value['chapter'];
      });
    });
  }

  @override
  void initState() {
    super.initState();
    getBookContent(widget.bookLink);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        leading: IconButton(
          icon: const Icon(Icons.keyboard_backspace),
          onPressed: () {
            Navigator.pop(context);
          },
          color: Colors.white,
        ),
        actions: <Widget>[
          IconButton(
            icon: const Icon(Icons.share),
            onPressed: () {
              Navigator.pushNamed(context, 'classify');
            },
            color: Colors.white,
          )
        ],
        backgroundColor: const Color(0xff343434),
      ),
      drawer: Drawer(
        elevation: double.infinity,
        child: Catalog(bookId: widget.bookId),
      ),
      body: const Center(
        child: Text('data'),
      ),
      bottomNavigationBar: Row(
        children: const <Widget>[
          Icon(Icons.book),
          Icon(Icons.book),
          Icon(Icons.book),
          Icon(Icons.book)
        ],
      ),
    );
  }
}
